<?php
class Control_Announce_addTags {

	function addTags() {
		$action = MooForm::request('action');
		if($action == 1) {
			$tagsName = MooForm::request('tagsName');
			
			$tagsDao = MooDao::get('Tags');
			
			$tagObj = $tagsDao->load(array('t_tag' => $tagsName));
			if ($tagObj) {
				$return['code'] = 2;
				$return['msg']  = "该tagName已存在";
				$this->backMsg($return);
			}
			
			$tagsDao->setData('t_tag', $tagsName);
			$tagsDao->setData('t_infos', "");
			
				$return['code'] = 3;
			if(!$tagsDao->insert()) {
				$return['msg']  = "保存失败";
				$this->backMsg($return);
			}
			
			$return['msg']  = "添加成功";
			$return['code'] = 1;
			$this->backMsg($return);
			
		} else {
			MooView::render('announceAddTags');
		}
	}
	private function backMsg($return) {
		exit(json_encode($return));
	}
}